<?php
defined('BASEPATH') OR exit('No direct script access allowed');

	//添加栏目
	class Editor extends MY_Controller{

	public function add(){
		$this->load->helper('form');
		$this->load->view('admin/add_article.html');  
	}

	//查看栏目
	public function show_column(){
		// echo '查看栏目';
		$this->load->model('Column_model','cate');
		//$this->cate->model_show();
		$data['editor'] = $this->cate->model_show();
		$this->load->view('admin/show_column.html',$data);
	}

	//添加栏目动作
	public function add_active(){
		$this->load->library('form_validation');
		$status = $this->form_validation->run('cate');
		if($status){

			//echo '数据库操作';
			$data = array(
				'cname' => $this->input->post('cname')
			);
			$this->load->model('Column_model','cate');
			$this->cate->model_add($data);
			success('admin/editor/show_column','添加成功');
			// $this->load->model(模型名)

			// $this->模型名->方法名

		}else{
			$this->load->helper('form');
			$this->load->view('admin/add_article.html');
		}
	}

	//编辑栏目
	public function editor_add(){
		$cid = $this->uri->segment(4);
		//echo $cid;
		$this->load->model('Column_model','cate');
		$data['editor'] = $this->cate->model_editor($cid);
		$this->load->helper('form');
		$this->load->view('admin/editor_add.html',$data);
	}

	//编辑栏目动作
	public function editor_adds(){
		$this->load->library('form_validation');
		$status = $this->form_validation->run('cate');
		if($status){
			$this->load->model('Column_model','cate');
			$cid = $this->input->post('cid');
			$cname = $this->input->post('cname');
			$data = array(
				'cname' => $cname
				//'cid' => $cid
			);
			$data['editor'] = $this->cate->model_update($cid,$data);
			success('admin/editor/show_column','添加成功');
		}else{
			$this->load->helper('form');
			$this->load->view('admin/editor_add.html');
		}
	}

	//删除栏目
	public function column_del(){
		$cid = $this->uri->segment(4);
		//echo $cid;die;
		$this->load->model('Column_model','cate');
		$this->cate->model_del($cid);
		success('admin/editor/show_column','删除成功');
	}
}